package leetcode_day._2021._202112._2131;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author yzh
 * @version 1.0
 * @date 2021/12/26 12:00
 * Bigram 分词
 * 算法：模拟
 */
public class _26_1078 {
    public static void main(String[] args) {
        String text = "alice is aa good girl she is a good student";
        System.out.println(Arrays.toString(new _26_1078().findOcurrences(text, "a", "good")));
    }

    public String[] findOcurrences(String text, String first, String second) {
        final String[] s = text.split(" ");
        List<String> ans = new ArrayList<>();
        for (int i = 0; i < s.length - 2; i++)
            if (s[i].equals(first) && s[i + 1].equals(second)) ans.add(s[i + 2]);
        return ans.toArray(new String[ans.size()]);
    }

}
